package com.ny.mapper;

import com.ny.entity.Device;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface DeviceMapper {

    // 查询所有设备
    @Select("select * from device")
    List<Device> findAllDevices();

    // 根据设备名称查询（模糊匹配）
    @Select("select * from device where device_name like concat('%', #{name}, '%')")
    List<Device> findDevicesByName(@Param("name") String name);

    // 根据设备ID查询（用于验证删除的设备是否存在）
    @Select("select * from device where device_id = #{id}")
    Device findDeviceById(@Param("id") int id);

    // 根据设备ID删除
    @Delete("delete from device where device_id = #{id}")
    int deleteDeviceById(@Param("id") int id);
}
